Send Program Resource to Report

edited 10:16AM in FastReport .NET
Hello everyone!

I am working on a new report and want to display some icons / resources from my application in the report.

Is this possible? I know that I can send file paths to the report and have it load the image in the report, but can I send actual resources? They're very small files, only icons, but there are several of them...

I was playing around with this, but I don't see a function that seems like it would do this, so I wanted to ask on here.

I appreciate the help as always!

Comments

  • edited 10:16AM
    ipong wrote: »

    Thank you very much, I appreciate your help.

    One quick question, is this limited to one resource? I've been working on this today and I can get one to populate in the report, but no more...

    I'm going to work on this again tomorrow, maybe I can figure it out. It just seemed odd that the code worked for one image, but not for the other images...

    Thanks Again!
  • edited 10:16AM
    it is not limited to one resource, basically, passing image to fastreport as parameter:
                // create parameter
                FastReport.Data.Parameter parameter = new FastReport.Data.Parameter();
                parameter.Name = "Logo";
                parameter.DataType = typeof(Byte[]);
                report.Dictionary.Parameters.Add(parameter);
                report.SetParameterValue("Logo", logo);
    
                // create another parameter
                FastReport.Data.Parameter another= new FastReport.Data.Parameter();
                another.Name = "Another";
                another.DataType = typeof(Byte[]);
                report.Dictionary.Parameters.Add(another);
                report.SetParameterValue("Another", anotherLogo);
    

    and in report script:
            private void _StartReport(object sender, EventArgs e)
            {
                Image image = Report.GetParameterValue("Logo") as Image;
                Picture1.Image = image;
                Image another = Report.GetParameterValue("Another") as Image;
                Picture2.Image = another;
            }
    
  • edited March 2018
    Thank you very much for your help. I didn't get a chance to work on this as much as I wanted to yesterday, so I spent more time this morning playing around with it.

    I was able to get this working, by commenting out the Parameter.Name line like this:

    // create parameter
    FastReport.Data.Parameter parameter = new FastReport.Data.Parameter();
    //parameter.Name = "Logo";
    parameter.DataType = typeof(Byte[]);
    report.Dictionary.Parameters.Add(parameter);
    report.SetParameterValue("Logo", logo);

    Not sure why, but with that line included the images weren't displaying in the report. The one that was working had a typo in that line, which is how I noticed this.

    Just figured I would let you know, as it seemed a bit strange to me.

    But it is working now and I wanted to thank you for your help! >

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.